package com.test;

public class StringTest4 {
    public static void main(String[] args) {
        //默认创建一个长度为16的字节数组
        //添加的内容长度小于16，直接存
        //添加的内容大于16会扩容（原来的容量*2+2)
        //如果扩容之后还不够，以实际长度为准
        StringBuilder builder = new StringBuilder();
        //容量:最多装多少
        //长度:已经装了多少
        System.out.println(builder.capacity());
        System.out.println(builder.length());
        System.out.println("---------");

        builder.append("abc");
        System.out.println(builder.capacity());
        System.out.println(builder.length());
        System.out.println("---------");

        builder.append("defghijklmnoqprstuvwxyz");
        System.out.println(builder.capacity());
        System.out.println(builder.length());
        System.out.println("---------");

        builder.append("0123456789");
        System.out.println(builder.capacity());
        System.out.println(builder.length());
        System.out.println("---------");
    }
}
